﻿using Business.Common;
using Business.PubInfo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_ucFileDownPart : System.Web.UI.UserControl
{
    //默认展示记录条数
    private int nRecordCount = 5;
    public int RecordCount
    {
        set { nRecordCount = value; }
        get { return nRecordCount; }
    }

    //显示的相对路径../FileDown/
    private string strPath = "";
    public string FilePath
    {
        set { strPath = value; }
        get { return strPath; }
    }

    /// <summary>
    /// 隐藏字符的长度
    /// </summary>
    private int nHideLength = 30;
    public int HideLength
    {
        set { nHideLength = value; }
        get { return nHideLength; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }

    public string GetAllHtml()
    {
        List<string> lstFiles = FileOperation.GetDir(Server.MapPath(FilePath));

        string strReturn = string.Empty;
        int nLength = nRecordCount;
        if(lstFiles.Count<nRecordCount)
        {
            nLength = lstFiles.Count;
        }
        for (int i = 0; i < nLength; i++)
        {
            strReturn += "<p><i></i>";
            strReturn += string.Format("<a href='{0}/{1}' target='_blank'>{1}  </a><span></span>", FilePath, lstFiles[i]);
            strReturn += " </p>";
        }
        return strReturn;
    }
}